!function (e, $, mui) {
    "use strict";
	var config = {
	};
	// 定义页面
	var p = function(config) {
		var t = this;
		t.config = config;
		t.userInfo = null;
		t.page = {
			page: 0,
			perpage: 0,
			more: true
		};
		t.element = {
			nickname: $('.left-nav .nickname'),
			logout: $('.left-nav .logout'),
			exit: $('.left-nav .exit'),
			listContainer: $('#list-container .list'),
			emptyContainer: $('#list-container .empty-list'),
			my: $('.bottom-nav .my')
		};
		// 初始化
		t.init();
		
		// 事件监听
		t.listen();
	};
	
	var pt = p.prototype;
	
	// 页面初始化
	pt.init = function () {
		var t = this;
		t.userInit();
		// 页面初始化
		t.element.nickname.text(t.userInfo.Pname || '');
		// 列表加载
//		t.listInit();
	};
	
	// 事件初始化
	pt.listen = function() {
		var t = this;
		t.element.my.on('tap', function () {
			mui('.mui-off-canvas-wrap').offCanvas().show();
		});
		// 注销
		t.element.logout.on('tap', function () {
			userLogout();
		});
		// 退出
		t.element.exit.on('tap', function () {
			plus.runtime.quit();
		});
	};
	
	// 用户信息初始化
	pt.userInit = function() {
		var t = this;
		t.userInfo = getLocalUserInfo();
	};
	
	e.page = new p(config);
	mui.init({
		keyEventBind: {
			backbutton: true //开启back按键监听
		}
	});
	// 页面初始化
	mui.plusReady(function () {
		// 登录判断
		checkUserLogin();
		
		var tuichu = "再按一次退出程序";
		var backButtonPress = 0;

		// 关闭所有无用窗口
		clearAllWindows();
		plus.navigator.setStatusBarBackground('#3E7FC3');
		
		mui.back = function(event) {
			backButtonPress++;
			if(backButtonPress > 1) {
				var main = plus.android.runtimeMainActivity();
				main.moveTaskToBack(false);
				return false;
			} else {
				plus.nativeUI.toast(tuichu);
			}
			setTimeout(function() {
				backButtonPress = 0;
			}, 1000);
			return false;
		};
	});

}(window, $, mui);